<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> 叫餐  <{$smarty.const.WEB_NAME}></title>
	<link rel="stylesheet" type="text/css" href="./skin/default/style.css" />
	<link rel="stylesheet" type="text/css" href="./skin/default/winBox.css" />
	<script type="text/javascript" src="./skin/default/comm.js"></script> 
	<script type="text/javascript" src="./skin/default/showDialog.js"></script> 
	<style type="text/css">
	     .tableList { margin-left:1px; *margin-left:0; _margin-left:0; }	
		 .list .title table{   margin-left:20px	 }
		 .info {background-color:#FFECC6; border:solid 1px #FFCC66; width:200px; font-weight:900;padding:5px; margin:50px auto;}
	</style>	
</head>
 <body>
       <{include file="#header.html"}>
	
     <div class="box">
	    <div class="title">
		   <div class="left" style="width:300px; padding-top:20px;padding-left:20px;">
			 <input type="button" value="叫餐" onclick="location.href = 'index.php?q=todayMenu'" />&nbsp;&nbsp;
			 <input type="button" value="商家管理" onclick="location.href = 'index.php?q=mealType'" />
			 <input type="button" value="添加商家" onclick="addMax();" />
		   </div>
		   <div class="right"></div>
		</div>
		<div class="list">
<{if $maxType|@count == 0}>
<div class="info">暂无数据 </div>
<{/if}>

 <{section name=list loop=$maxType}>
 <table width="700" border="0" align="center" cellspacing="0" cellpadding="0" >
   <tr>
     <td>
	 <div class="wordBox">
       <div class="tit">
	     <table width="95%" cellspacing="0" border="0" cellpadding="0">
	       <tr>
			 <td class="con" fid="<{$maxType[list].id}>" fname="<{$maxType[list].name}>">
			   <{$maxType[list].name}>
		    </td>
			 <td align="center" width="25%">
			   <a href="#" onclick="addMin(<{$maxType[list].id}>)">添加新菜</a> <a href="#" onclick="editMax(this)">修改</a></b> 
			    <{if $smarty.session.type > 0}>
			   <a href="javascript:deleteArticle('index.php?q=removeMeal&id=<{$maxType[list].id}>')">删除</a>
			   <{/if}>
		    </td>
	       </tr>
	     </table>
	   </div>
	   <div class="lists" id="list_318">
	     <{section name=min loop=$minType}>
			<{if $maxType[list].id == $minType[min].parentId}>
			 <div class="titles">
			    <table width="85.6%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
				    <td><{$minType[min].name}></td>
				    <td width="8%">￥<{$minType[min].price}></td>
				    <td width="10%" fid="<{$minType[min].id}>" fprice="<{$minType[min].price}>" fname="<{$minType[min].name}>" fparent="<{$minType[min].parentId}>">
					<a href="#" onclick="editMin(this)">修改</a> 
					<{if $smarty.session.type > 0}>
					 <a href="javascript:deleteArticle('index.php?q=removeMeal&id=<{$minType[min].id}>')">删除</a>
					 <{/if}>
					</td>
				  </tr>
				</table>			 
			 </div>
			 <{/if}>
		 <{/section}>
       </div>
	</div>
 <{/section}>


		</div>
	    <div class="bottom">
		   <div class="left"></div>
		   <div class="right"></div>		
		</div>	 
	 </div>

 <div id="maxBox" style="display:none">
   <form method="post" id="form1" onsubmit="return submitValidate('form1')">
   <input type="hidden" id="maxId" name="id" />
    <table width="100%" align="center" cellspacing="0" cellpadding="0">
      <tr>
        <th>商家名称</th>
        <td><input type="text" id="maxName" name="name" /></td>
      </tr>
	  <tr>
	    <td colspan="2" align="center">
		   <input type="submit" class="submit" value="提交"/>
		</td>
	  </tr>
    </table>
   </form>
 </div>



 <div id="minBox" style="display:none">
   <form method="post" id="form2" action="" onsubmit="return submitValidate('form2')">
    <input type="hidden" id="minFid" name="parentId" />
    <input type="hidden" id="minId" name="id" />   
    <table width="100%" align="center" cellspacing="0" cellpadding="0">
      <tr>
        <th>菜名</th>
        <td><input type="text" id="minName" name="name" /></td>
      </tr>
      <tr>
        <th>价格</th>
        <td><input type="text" id="price" name="price" size="3" /><code class="red">使用纯数字<code></td>
      </tr>
	  <tr>
	    <td colspan="2" align="center">
		   <input type="submit" class="submit" value="提交"/>
		</td>
	  </tr>
    </table>
   </form>
 </div>

 </td>
   </tr>
 </table>


<script type="text/javascript">
<!--
	function addMax(){
	  showDialog('添加商家' , 'maxBox');
	  get('form1').action = 'index.php?q=addMeal';
	  get('maxId').value = '';
	  get('maxName').value = '';
	  get('maxName').focus();
	}
	function editMax(obj){
	  showDialog('修改商家' , 'maxBox');
	  get('form1').action  = 'index.php?q=editMeal';
	  obj = obj.parentNode.parentNode.cells[0];
	  get('maxId').value = obj.getAttribute('fid');
	  get('maxName').value = obj.getAttribute('fname');
	  get('maxName').focus();
	}

	function addMin(fid){
	  showDialog('添加菜名' , 'minBox');
	  get('form2').action = 'index.php?q=addMeal';
	  get('minFid').value = fid;
	  get('minId').value = '';
	  get('minName').value = '';
	  get('price').value = '6';
	}

	function editMin(obj){
	   showDialog('修改菜名' , 'minBox');
	   get('form2').action  = 'index.php?q=editMeal';
	   get('minFid').value = obj.parentNode.getAttribute("fparent");
	   get('minId').value = obj.parentNode.getAttribute("fid");
	   get('minName').value = obj.parentNode.getAttribute("fname");
	   get('price').value = obj.parentNode.getAttribute("fprice");
	}

	function submitValidate(name){
	  var list = get(name);
	  for (var i = 0; i < list.length ; i++){
	     if('text' == list[i].type){
		     if("" == list[i].value){
			   alert("不能为空");
			   list[i].focus();
			   return false;
			 }
		 }
	  }
	}
//-->
</script>
</body>
</html>
